package com.maxd.service.article;

import com.maxd.model.ArticleBrowsingHistory;
import com.maxd.respository.article.ArticleBrowsingHistoryJpaRepository;
import com.maxd.respository.article.ArticleBrowsingHistoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 *  浏览记录
 */
@Service
public class ArticleBrowsingHistoryServiceImpl implements ArticleBrowsingHistoryService {

    @Autowired
    private ArticleBrowsingHistoryJpaRepository articleBrowsingHistoryJpaRepository;
    @Autowired
    private ArticleBrowsingHistoryRepository articleBrowsingHistoryRepository;

    @Override
    public ArticleBrowsingHistory save(ArticleBrowsingHistory articleBrowsingHistory) {
        return articleBrowsingHistoryJpaRepository.save(articleBrowsingHistory);
    }

    @Override
    public Long selectCount(Long articleId, Long userId) {
        return articleBrowsingHistoryRepository.selectCount(articleId,userId);
    }

    @Override
    public Page<ArticleBrowsingHistory> selectArticleBrowsingHistoryList(Long userId, Pageable pageable) {
        return articleBrowsingHistoryRepository.selectArticleBrowsingHistoryList(userId,pageable);
    }

    @Override
    public int updateCreateTimeById(Long Id, Date createTime) {
        return articleBrowsingHistoryRepository.updateCreateTimeById(Id, createTime);
    }


}
